using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
using System.Collections;
using System.Data.SqlClient;
using System.Data;

namespace DIEMRENLUYENSV.Class
{
    class Ketnoi
    {
        Class.B_CHUCVU x;
        private SqlConnection cn;
        private Server _server;


        public Server _Server
        {
            get { return _server; }
            set { _server = value; }
        }
        public Ketnoi()
        {
            ServerConnection serverCon = new ServerConnection();
            serverCon.LoginSecure = false;
            serverCon.ServerInstance = ".";
            serverCon.Login = "sa";
            serverCon.Password = "sa";
            _server = new Server(serverCon);

        }
        public Ketnoi(string servername, string user, string pass)
        {
            ServerConnection serverCon = new ServerConnection();
            serverCon.LoginSecure = false;
            serverCon.ServerInstance = servername;
            serverCon.Login = user;
            serverCon.Password = pass;
            _server = new Server(serverCon);
        }
        //public SqlConnection SqlCN
        //{
        //    get
        //    {
        //        return cn;
        //    }
        //    set
        //    {
        //        cn = value;
        //    }
        //}
        //public Boolean Ketnoi2()
        //{
        //    if (cn.State == ConnectionState.Closed)
        //    {
        //        cn.Open();
        //        return true;
        //    }
        //    else return false;

        //}
        //public Boolean kiemtratinhtrangma(string tenbang, string tenma, string ID)
        //{
            
        //    string caulenh = "SELECT count(*) from " + tenbang + " where " + tenma + " = '" + ID + "' and XOA = 'true' ";
        //    DataTable s = new DataTable();
        //    int kq;
        //    SqlCommand com = new SqlCommand(caulenh, cn.SqlCN);
        //    kq = (int)com.ExecuteScalar();
        //    if (kq > 0)
        //    {
        //        return true;
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //}
    }
}
